<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layuiAdmin 后台管理员</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="__STATIC__/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="__STATIC__/layuiadmin/style/admin.css" media="all">
</head>
<body>

<form class="layui-form"  lay-filter="example">
  <div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
  <div class="layui-form-item">
    <label class="layui-form-label">账户名称</label>
    <div class="layui-input-inline">
      <input type="text" name="username" disabled="true" readonly="true" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input" value="{$userData['username']}">
      <input type="hidden" name="id" value="{$userData['id']}">

    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">原始密码</label>
    <div class="layui-input-inline">
      <input type="text" name="oldPassword" lay-verify="required" placeholder="请输入原始密码" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">最新密码</label>
    <div class="layui-input-inline">

      <input type="text" name="newPassword" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">再次确认</label>
    <div class="layui-input-inline">

      <input type="text" name="agingPassword" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
    </div>
  </div>

    <div class="layui-form-item">
      <div class="layui-input-block">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    <div>




</div>

</form>
 <script src="__STATIC__/layuiadmin/layui/layui.js"></script>
  <script>
  layui.config({
    base: '__STATIC__/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'table'], function(){
    var $ = layui.$
    ,form = layui.form
    ,table = layui.table;

//监听提交
    form.on('submit(demo1)', function(data){
      // console.log(data.field);
      if (data.field.newPassword != data.field.agingPassword ) {
        layer.msg('两次密码输入不相同~~', {
          offset: '15px'
          ,icon: 2
          ,time: 3000
        });
        return false;
      }
      $.ajax({
        url:"password",
        type:"POST",
        dataType:"json",
        data:data.field,
        success:function (res) {
          console.log(res);
          if (res.code == 0){
            //操作失败
            layer.msg(res['msg'], {
              offset: '15px'
              ,icon: 2
              ,time: 3000
            });
          }

          if (res['code'] == 1) {
            //操作成功
            layer.msg(res['msg'], {
              offset: '15px'
              ,icon: 1
              ,time: 1000
            },function () {
              // location.href = './index'; //后台主页
            });
          }
        }
      });

      // layer.alert(JSON.stringify(data.field), {
      //   title: '最终的提交信息'
      // });
      return false;
    });













  });
  </script>
</body>
</html>

